﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace Web.backStage.file
{
    public partial class addVideo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void SaveBtn_Click(object sender, EventArgs e)
        {
            // 验证必填项是否填写


            Model.Video video = new Model.Video();
            video.VideoName = NameTxt.Text;
            video.VideoType = Int32.Parse(TypeDropList.SelectedValue);
            video.VideoCreatedDate = PublicDateTxt.Text;
            video.VideoMaker = ManufactureTxt.Text;
            video.VideoImage = "images/" + FileUpload2.FileName;
            video.VideohotScore = HotScoreDropList.SelectedIndex + 1;
            video.VideoSummary = BriefIntroTxt.Text;
            video.VideoDirector = DirectorTxt.Text;
            video.VideoActors = ActorsTxt.Text;
            video.VideoLanguage = LanguageTxt.Text;
            video.VideoNation = LocationTxt.Text;
            video.VideoURL = FileUpload1.FileName;
            video.VideoUploadDate = DateTime.Now.ToString();
            video.VideoFileType = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            video.VideoTypeName = TypeDropList.SelectedItem.Text.Trim();
            video.IsTry = CheckBox1.Checked;

            //***************************************
            // 各种填各种数据
            //***************************************

            BLL.videoLib.VideoManager.AddVideo(video);

            //***************************************
            //上传文件和海报
            //***************************************
            FileUpload1.PostedFile.SaveAs(Server.MapPath("~").Replace('\\', '/') + "movies/" + FileUpload1.FileName);
            FileUpload2.PostedFile.SaveAs(Server.MapPath("~").Replace('\\', '/') + "frontStage/images/" + FileUpload2.FileName);
        }
    }
}